package util.dbutil;

import bean.GiveMoney;
import bean.Student;
import org.apache.commons.dbutils.QueryRunner;
import util.C3p0Util;

import java.sql.SQLException;

public class LoginGiveMoney {
    public int insertGiveMoney(GiveMoney giveMoney){
        int count = 0;
        QueryRunner runner = new QueryRunner(C3p0Util.getDs());
        String sql = "insert into t_giveMoney (gm_s_number,gm_s_name,gm_s_cNumber,gm_s_tel,gm_intime,gm_gimoney,gm_acmoney,moremoney) values (?,?,?,?,?,?,?,?)";

        try {
            /*
                - update DML 针对增、删、改的语句都可以使用
                    参数1：sql
                    参数2：可变数组，存放的是占位符对应的数据值
             */
            count = runner.update(sql,giveMoney.getGmsNumber(),giveMoney.getGmsName(),giveMoney.getGmsCNumber(),giveMoney.getGmsTel(),giveMoney.getGmInTime(),giveMoney.getGmgiMoney(),giveMoney.getGmacMoney(),giveMoney.getMoreMoney());
            if(count > 0){
                System.out.println("执行成功");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return count;
    }
}
